/**
*      author: Y_Yao
*      created: 2024-09-22 23:25:26
**/

#include<bits/stdc++.h>

using namespace std;
int dx[8] = {1,2,2,1,-1,-2,-2,-1};
int dy[8] = {2,1,-1,-2,2,1,-1,-2};
using LL = long long;
const int INF = 0x3f3f3f3f;
int n,m;
int nums[409][409];
bool vis[409][409];

struct node
{
    int x,y,step;
};

void bfs(int x,int y)
{
    queue<node> q;
    node tmp;
    tmp.x = x,tmp.y = y,tmp.step = 0;
    q.push(tmp);
    vis[x][y] = true;
    
    while(!q.empty())
    {
        auto node1 = q.front();
        q.pop();
        nums[node1.x][node1.y] = node1.step;


        for(int i = 0;i < 8;i++)
        {
            int x1 = node1.x + dx[i],y1 = node1.y + dy[i];
            if(x1 < 0 || x1 >= n || y1 < 0 || y1 >= m || vis[x1][y1])
                continue;
            node node2;
            node2.x = x1,node2.y = y1;
            node2.step = node1.step+1;
            q.push(node2);
            vis[x1][y1] = true;
        }
        
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    int x,y;
    cin >> x >> y;
    bfs(x-1,y-1);

    
    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < m;j++)
        {
            if(nums[i][j] == 0 && i != x - 1 && j != y - 1)
            {
                nums[i][j] = -1;
            }
        }
    }

    for(int i = 0;i < n;i++)
    {
        for(int j = 0;j < m;j++)
        {
            cout<<nums[i][j]<<" ";
        }
        cout<<endl;
    }
    return 0;
}

